/**
 * @class Ext.Number
 *
 * A collection of useful static methods to deal with numbers
 * @singleton
 */
define(function() {
	aries.Number = new function() {

		var me = this,
		isToFixedBroken = (0.9).toFixed() !== '1',
		math = Math;
	
		$.extend(this, {
			/**
			* Checks whether or not the passed number is within a desired range.  If the number is already within the
			* range it is returned, otherwise the min or max value is returned depending on which side of the range is
			* exceeded. Note that this method returns the constrained value but does not change the current number.
			* @param {Number} number The number to check
			* @param {Number} min The minimum number in the range
			* @param {Number} max The maximum number in the range
			* @return {Number} The constrained value if outside the range, otherwise the current value
			*/
			constrain: function(number, min, max) {
				var x = parseFloat(number);
			
				// Watch out for NaN in Chrome 18
				// V8bug: http://code.google.com/p/v8/issues/detail?id=2056
			
				// Operators are faster than Math.min/max. See http://jsperf.com/number-constrain
				// ... and (x < Nan) || (x < undefined) == false
				// ... same for (x > NaN) || (x > undefined)
				// so if min or max are undefined or NaN, we never return them... sadly, this
				// is not true of null (but even Math.max(-1,null)==0 and isNaN(null)==false)
				return (x < min) ? min : ((x > max) ? max : x);
			}
		});
		};
})